#include "stdafx.h"

PropertyMgr::PropertyMgr()
{
}

PropertyMgr::~PropertyMgr()
{
	for (AbstractProperty * prop : properties)
	{
		delete prop;
	}
}

PropertyMgr * PropertyMgr::getInstance()
{
	static PropertyMgr manager;

	return &manager;
}

void PropertyMgr::add(AbstractProperty * prop)
{
	properties.push_back(prop);
}

bool PropertyMgr::update(double dtime)
{
	std::vector<AbstractProperty *>::iterator it = properties.begin();

	while (it != properties.end())
	{
		if ((*it)->update(dtime))
		{
			it++;
		}
		else
		{
			delete *it;
			it = properties.erase(it);
		}
	}

	return true;
}

bool PropertyMgr::render()
{
	for (AbstractProperty * prop : properties)
	{
		prop->render();
	}

	return true;
}

bool PropertyMgr::clear()
{
	for (AbstractProperty * p : properties)
	{
		delete p;
	}

	properties.clear();

	return true;
}